package demo07Array类讲解;

import java.util.Arrays;

public class Demo07 {
    public static void main(String[] args) {

        int[] a = {1,2,3,4,9090,31231,543,21,3,23};

        System.out.println(a);//直接打的化是一个对象的hascode [I@154617c

        //打印数组元素
        System.out.println(Arrays.toString(a));
        System.out.println("====================================================================");
         printArray(a);


         Arrays.sort(a);//对他进行排序
        System.out.println("\n" + Arrays.toString(a));

        Arrays.fill(a,2,4,0);//数组填充
        System.out.println(Arrays.toString(a));


    }

    public static void printArray(int[] a){
        for (int i = 0; i < a.length ; i++) {
            if( i == 0){
                System.out.print("[");
            }
            if (i == a.length-1){
                System.out.print(a[i] + "]");
            }else {
                System.out.print(a[i] + ", ");
            }

        }

    }
}
